package com.bjtu.laorenyouhao.event.controller;

import java.util.Arrays;
import java.util.Map;

import com.bjtu.common.valid.group.AddGroupp;
import com.bjtu.common.valid.group.UpdateGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bjtu.laorenyouhao.event.entity.EventPeopleEntity;
import com.bjtu.laorenyouhao.event.service.EventPeopleService;
import com.bjtu.common.utils.PageUtils;
import com.bjtu.common.utils.R;



/**
 * 事件人员表
 *
 * @author yangyalong
 * @email yangyalong@gmail.com
 * @date 2021-07-08 21:00:01
 */
@RestController
@RequestMapping("event/eventpeople")
public class EventPeopleController {
    @Autowired
    private EventPeopleService eventPeopleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = eventPeopleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		EventPeopleEntity eventPeople = eventPeopleService.getById(id);

        return R.ok().put("eventPeople", eventPeople);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@Validated(AddGroupp.class) @RequestBody EventPeopleEntity eventPeople){
		eventPeopleService.save(eventPeople);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@Validated(UpdateGroup.class) @RequestBody EventPeopleEntity eventPeople){
        System.out.println(eventPeople);
		eventPeopleService.updateById(eventPeople);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		eventPeopleService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
